package com.niiwoo.civet.user.service.duboo;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.activity.stage.dto.request.content.LittleBoyUserRoleDTO;
import com.niiwoo.activity.stage.service.content.LittleByMsgDubboService;
import com.niiwoo.civet.user.dto.request.UpdateUserBasicInfIMRequestDTO;
import com.niiwoo.civet.user.service.ActivityDubboService;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;

@Slf4j
@Service(version = "1.0.0")
public class ActivityDubboServiceImpl implements ActivityDubboService {
    @Reference(version = "1.0.0")
    private LittleByMsgDubboService littleByMsgDubboService;

    @Override
    public void synToActivity(UpdateUserBasicInfIMRequestDTO requestDTO) {
        try {
           LittleBoyUserRoleDTO reqDTO = new LittleBoyUserRoleDTO();
           reqDTO.setUserId(requestDTO.getGuid());
           reqDTO.setUserRole(requestDTO.getAddIdentity());

           CompletableFuture.runAsync(() -> littleByMsgDubboService.synUserInfo(reqDTO));
        } catch (Exception e) {
            log.error("同步用户角色给活动失败: userId={}, errorMessage={}", requestDTO.getGuid(),e.getMessage());
        }
    }
}
